package devices

import (
	"context"
	"device_srv/device"
	"device_srv/internal/dao"
	"device_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DevicesDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDevicesDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DevicesDetailLogic {
	return &DevicesDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DevicesDetail 查看设备详情
func (l *DevicesDetailLogic) DevicesDetail(in *device.DevicesDetailRequest) (*device.DevicesDetailResponse, error) {
	//调用业务逻辑
	detail, err := dao.DevicesDetail(in)
	if err != nil {
		return nil, err
	}
	return &device.DevicesDetailResponse{
		BrandId:           int64(detail.BrandId),
		DeviceName:        detail.DeviceName,
		DeviceModel:       detail.DeviceModel,
		DeviceDescription: detail.DeviceDescription,
		PurchaseDate:      detail.PurchaseDate,
		Status:            int64(detail.Status),
	}, nil
}
